words = input().split()
if len(words) != 3:
    print("Wrong input")
else:
    numbers = {"zero": 0, "one": 1, "two": 2, "three": 3, "four": 4, "five": 5, "six": 6, "seven": 7, "eight": 8, "nine": 9, }
    num = numbers[words[0]] * 100 + numbers[words[1]] * 10 + numbers[words[2]]
    if num <= 1:
        print("Wrong input")
    else:
        flag = False
        while not flag:
            flag = True
            for i in range(2, int(num ** 0.5) + 1):
                if num % i == 0:
                    num += 1
                    flag = False
                    break
        print(num)
